#include "OLogListener.h"
#include "QLogger.h"
#include <QThread>
#include <QtDebug>

OLogListener::OLogListener(void)
{
}

OLogListener::~OLogListener(void)
{
}

void OLogListener::messageLogged( const Ogre::String &message, Ogre::LogMessageLevel lml, 
								 bool maskDebug, const Ogre::String &logName ){
	qDebug() << message.c_str();
	_buffer.append(message.c_str());
	_buffer.append("<br>");
	if ( qApp && qApp->thread() == QThread::currentThread() ){
		QLogger::getInstance()->append(_buffer);
		_buffer.clear();
	} // only append message to QLogger when the calling thread is the main GUI thread.
}
